﻿
<%@ Page Title="IVR Junction Content Moderation" Language="C#" MasterPageFile="~/IVRJunctionUI.Master" AutoEventWireup="true" CodeBehind="ContentModeratioChannel.aspx.cs" Inherits="IVRJunctionUI.ContentModerationChannel" %>
<%@ Import Namespace="DatabaseLayer" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" runat="server">
    <center>
        <h2> Content Moderation Channel</h2>
    </center>
    <br />
    <asp:Panel ID="PanelModeration" runat="server" BorderStyle="Solid" BackColor="#EBEBEB"
        Visible="true">
        <br />
        &nbsp;&nbsp;
        <asp:Label ID="LabelModeration" runat="server" Font-Bold="True" Text="Content Moderation Channel"></asp:Label>
        <br />
        <%
             
            DatabaseFunctions objectDatabaseFunctions = new DatabaseFunctions();
            var configuration = objectDatabaseFunctions.getIVRJunctionConfiguration();

            if (configuration != null)
            {
                var genericConfigurationInformation = configuration.Item6;
                var channelAccountName = configuration.Item3.Item2;
                hyperLink.NavigateUrl= "http://www.youtube.com/user/" + channelAccountName;
                if (genericConfigurationInformation.Item1)
                {
                    GridView1.Visible = false;
        %>
        <asp:Table runat="server" CellSpacing="20">
            <asp:TableRow>
                <asp:TableCell>
                 Moderation Channel is selected as online. Please visit the <asp:HyperLink  Id='hyperLink' runat='server' Target='_blank'>channel page</asp:HyperLink> of configured YouTube Account to moderate
                  audio recordings!
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
        <%
                         
                }
                else
                {
                    GridView1.Visible = true;
        %>
        
        <asp:Table runat="server" CellSpacing="20">
            <asp:TableRow>
                <asp:TableCell>
                 Moderation Channel is selected as offline. Please modify the table below to moderate the items!
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
       
        <%
                }
            }
            else
            {
                GridView1.Visible = false;
               
        %>
        <asp:Table ID="Table1" runat="server" CellSpacing="20">
            <asp:TableRow>
                <asp:TableCell>
                 SQL Error, please try after some time!
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
        <%
            }
           
        
        %>
    </asp:Panel>
    <br />
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" BackColor="#CCCCCC" BorderColor="#999999" 
        BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" 
        DataKeyNames="RecordingFileLocation" DataSourceID="SqlDataSource1" 
        ForeColor="Black" onrowupdating="GridView1_RowUpdating">
        <Columns>
            <asp:TemplateField HeaderText="File Location" 
                SortExpression="RecordingFileLocation">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" 
                        Text='<%# Eval("RecordingFileLocation") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" 
                        Text='<%# Bind("RecordingFileLocation") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:HyperLinkField DataNavigateUrlFields="RecordingURL" 
                DataTextField="RecordingURL" HeaderText="URL">
            <ItemStyle HorizontalAlign="Center" />
            </asp:HyperLinkField>
            <asp:TemplateField HeaderText="Phone Number" SortExpression="PhoneNumber">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("PhoneNumber") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("PhoneNumber") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Date" SortExpression="DateTimeNow">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("DateTimeNow") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("DateTimeNow") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:BoundField DataField="BranchId" HeaderText="BranchId" ReadOnly="True" 
                SortExpression="BranchId" />
            <asp:TemplateField HeaderText="Published?" SortExpression="IsPrivate">
                <EditItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" 
                        Checked='<%# Antonym(Eval("IsPrivate")) %>' />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" 
                        Checked='<%# Antonym(Eval("IsPrivate")) %>' />
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:CommandField HeaderText="Actions" ShowDeleteButton="True" 
                ShowEditButton="True" ShowHeader="True" />
        </Columns>
        <FooterStyle BackColor="#CCCCCC" />
        <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
        <RowStyle BackColor="White" />
        <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="Gray" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#383838" />
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:IVRDatabaseConnectionString %>" 
        DeleteCommand="DELETE FROM RecordingData WHERE (RecordingFileLocation = @RecordingFileLocation)" 
        InsertCommand="INSERT INTO [RecordingData] ([RecordingFileLocation], [RecordingURL], [PhoneNumber], [DateTimeNow], [BranchId], [IsPrivate]) VALUES (@RecordingFileLocation, @RecordingURL, @PhoneNumber, @DateTimeNow, @BranchId, @IsPrivate,@Parent)" 
        SelectCommand="SELECT [RecordingFileLocation], [RecordingURL], [PhoneNumber], [DateTimeNow], [BranchId], [IsPrivate] FROM [RecordingData] ORDER BY [DateTimeNow] DESC" 
        UpdateCommand="UPDATE RecordingData SET PhoneNumber = @PhoneNumber, DateTimeNow = @DateTimeNow, IsPrivate = @IsPrivate WHERE (RecordingFileLocation = @RecordingFileLocation)">
        <DeleteParameters>
            <asp:Parameter Name="RecordingFileLocation" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="RecordingFileLocation" Type="String" />
            <asp:Parameter Name="RecordingURL" Type="String" />
            <asp:Parameter Name="PhoneNumber" Type="String" />
            <asp:Parameter Name="DateTimeNow" Type="DateTime" />
            <asp:Parameter Name="BranchId" Type="String" />
            <asp:Parameter Name="IsPrivate" Type="Boolean" />
            <asp:Parameter Name="Parent" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="PhoneNumber" Type="String" />
            <asp:Parameter Name="DateTimeNow" Type="DateTime" />
            <asp:Parameter Name="IsPrivate" Type="Boolean" />
            <asp:Parameter Name="RecordingFileLocation" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>
